package game.source.sound;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;

public class AudioBuffer{
	
	private byte[] sound;
	private AudioFormat format;
	
	public AudioBuffer(String path){
		try {
			AudioInputStream stream = AudioSystem.getAudioInputStream(AudioBuffer.class.getResource(path));
			this.format = stream.getFormat();
			this.sound = new byte[(int)(stream.getFormat().getFrameSize()*stream.getFrameLength())];
			stream.read(this.sound, 0, this.sound.length);
			stream.close();
		}catch (Exception e){
			e.printStackTrace();
		}
	}
	public byte[] getSound(){
		return this.sound;
	}
	public AudioFormat getFormat(){
		return this.format;
	}
	public int getLength(){
		return this.sound.length;
	}
}
